package com.xquant.databasemanagement.bean.table;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import javafx.beans.property.SimpleStringProperty;
import org.apache.commons.lang.StringUtils;


@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class IndexesBean {
    private final SimpleStringProperty indexesName = new SimpleStringProperty();
    private final SimpleStringProperty indexesColumn = new SimpleStringProperty();
    private final SimpleStringProperty indexesType = new SimpleStringProperty();
    private final SimpleStringProperty tablespace = new SimpleStringProperty();

    @JacksonXmlProperty(isAttribute = true)
    public String getTablespace() {
        return tablespace.get();
    }


    public SimpleStringProperty tablespaceProperty() {
        return tablespace;
    }

    @JacksonXmlProperty(isAttribute = true)
    public void setTablespace(String tablespace) {
        this.tablespace.set(tablespace);
    }

    @JacksonXmlProperty(isAttribute = true)
    public String getIndexesName() {
        return indexesName.get();
    }

    public SimpleStringProperty indexesNameProperty() {
        return indexesName;
    }

    @JacksonXmlProperty(isAttribute = true)
    public void setIndexesName(String indexesName) {
        this.indexesName.set(indexesName);
    }

    @JacksonXmlProperty(isAttribute = true)
    public String getIndexesColumn() {
        return indexesColumn.get();
    }

    public SimpleStringProperty indexesColumnProperty() {
        return indexesColumn;
    }

    @JacksonXmlProperty(isAttribute = true)
    public void setIndexesColumn(String indexesColumn) {
        this.indexesColumn.set(indexesColumn);
    }

    @JacksonXmlProperty(isAttribute = true)
    public String getIndexesType() {
        return indexesType.get();
    }

    public SimpleStringProperty indexesTypeProperty() {
        return indexesType;
    }

    @JacksonXmlProperty(isAttribute = true)
    public void setIndexesType(String indexesType) {
        this.indexesType.set(indexesType);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (obj instanceof IndexesBean){
            IndexesBean indexesBean = (IndexesBean) obj;
            return StringUtils.equals(indexesBean.getIndexesType(),this.getIndexesType()) &&
                    StringUtils.equals(indexesBean.getIndexesColumn(),this.getIndexesColumn()) &&
                    StringUtils.equals(indexesBean.getIndexesName(),this.getIndexesName()) &&
                    StringUtils.equals(indexesBean.getTablespace(),this.getTablespace());
        }
        return false;
    }
}
